package com.pucheng.bracelet.app.database

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.pucheng.bracelet.app.App
import com.pucheng.bracelet.app.database.dao.*
import com.pucheng.bracelet.data.bean.*

@Database(entities = [StepsBean::class, SleepBean::class,AllHertRateBean::class,Sao2Bean::class, BloodPressureBean::class, HertRateBean::class], version = 6)
abstract class AppDatabase : RoomDatabase() {

    companion object {
        @Volatile
        private var INSTANCE: AppDatabase? = null
        fun getDatabase(): AppDatabase {
            // if the INSTANCE is not null, then return it,
            // if it is, then create the database
            return INSTANCE ?: synchronized(this) {
                val instance = Room.databaseBuilder(
                    App.instance,
                    AppDatabase::class.java,
                    "watch_database"
                ).build()
                INSTANCE = instance
                // return instance
                instance
            }
        }
    }

    abstract fun sao2Dao(): Sao2Dao
    abstract fun stepsDao(): StepDao
    abstract fun sleepDao(): SleepDao
    abstract fun allHRDao(): AllDataHRDao

    abstract fun bloodPressureDao(): BPDao
    abstract fun hertRateDao(): HertRateDao
}